Skip to content

refactor(ai): rename provider id ai-gateway → vercel#788

Merged
softmarshmallow merged 1 commit into
mainfrom
refactor/byok-provider-id-vercel
Jun 6, 2026
Merged

refactor(ai): rename provider id ai-gateway → vercel#788
softmarshmallow merged 1 commit into
mainfrom
refactor/byok-provider-id-vercel

Conversation

@softmarshmallow

@softmarshmallow softmarshmallow commented Jun 6, 2026

Copy link
Copy Markdown
Member

Summary

The BYOK provider id "ai-gateway" was misleading — it's a service name, not a provider identity. Renamed to "vercel" to match how "openrouter" names its provider. Also renames the routing label on @grida/ai-models image-model cards from "gateway" to "vercel" for the same reason.

  • ByokProviderId (@grida/agent): "ai-gateway""vercel" (label "AI Gateway""Vercel")
  • models.Provider (@grida/ai-models): "gateway""vercel" (1 type + 10 image-model cards)
  • makeAiGatewayFactorymakeVercelFactory
  • Sandbox policy registry key renamed; allowlisted hosts unchanged (ai-gateway.vercel.sh, *.vercel-ai.com — those are the real URLs)

Preserved (intentional)

  • BYOK_AI_GATEWAY_API_KEY env var stays — it mirrors Vercel's own AI_GATEWAY_API_KEY convention; no point fighting upstream naming.
  • "AI Gateway" as a natural-language product name remains in prose, doc comments, and vercel.com/docs/ai-gateway/... URLs.

Breaking — by design, no compat shim

  • Local auth.json entries keyed "ai-gateway" are orphaned; desktop users will need to re-enter their Vercel BYOK key via the settings UI.
  • /secrets/* HTTP routes will reject provider_id: "ai-gateway" with 400; old desktop bridge clients sending the legacy id will fail.
  • @grida/ai-models consumers reading the provider field on image-model cards will see "vercel" instead of "gateway".

Verification

  • pnpm turbo build --filter=@grida/ai-models --filter=@grida/agent
  • pnpm turbo test --filter=@grida/ai-models --filter=@grida/agent ✅ 350 tests
  • pnpm exec vitest run lib/ai/__tests__/server.test.ts lib/desktop/bridge.test.ts ✅ 20 tests
  • pnpm turbo typecheck --filter=editor ✅ 38 tasks (editor + all deps)

Test plan

  • Desktop: confirm settings UI shows the renamed provider as "Vercel"
  • Desktop: confirm BYOK key entry under the new id reaches auth.json correctly
  • Web editor: confirm BYOK_AI_GATEWAY_API_KEY env var still activates the BYOK path

Summary by CodeRabbit

  • New Features

    • Updated Bring Your Own Key (BYOK) provider support: OpenRouter and Vercel are now the supported providers with OpenRouter as primary and Vercel as fallback.
  • Documentation

    • Updated configuration examples and provider documentation to reflect the new BYOK provider list and precedence order.

The BYOK provider id "ai-gateway" was misleading — it's a service name,
not a provider identity. Renamed to "vercel" to match how the other
entry ("openrouter") names its provider. Also renames the routing label
on @grida/ai-models cards from "gateway" to "vercel" for the same
reason.

- ByokProviderId: "ai-gateway" → "vercel" (label "AI Gateway" → "Vercel")
- models.Provider: "gateway" → "vercel" (1 type + 10 image-model cards)
- makeAiGatewayFactory → makeVercelFactory
- Sandbox policy key renamed; allowlisted hosts unchanged
  (ai-gateway.vercel.sh, *.vercel-ai.com — these are real URLs)
- BYOK_AI_GATEWAY_API_KEY env var preserved (mirrors Vercel's own
  AI_GATEWAY_API_KEY convention); "AI Gateway" prose preserved where
  it names the product

Breaking — by design, no compat shim:
- Local auth.json entries keyed "ai-gateway" are orphaned; desktop
  users will need to re-enter their Vercel BYOK key
- /secrets/* HTTP routes will 400 on provider_id: "ai-gateway"
- @grida/ai-models consumers will see provider: "vercel" on cards
@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 6, 2026 10:02am
grida Ready Ready Preview, Comment Jun 6, 2026 10:02am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
backgrounds Ignored Ignored Preview Jun 6, 2026 10:02am
blog Ignored Ignored Preview Jun 6, 2026 10:02am
code Ignored Ignored Jun 6, 2026 10:02am
legacy Ignored Ignored Jun 6, 2026 10:02am
viewer Ignored Ignored Preview Jun 6, 2026 10:02am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Worried about impact? Review this PR in Change Stack to explore blast radius before you approve or request changes.

Review Change Stack

Walkthrough

This PR updates the bring-your-own-key (BYOK) provider identifier and associated configuration throughout the codebase. The provider named "ai-gateway" is being renamed to "vercel" across type definitions, factory implementations, network policies, and documentation, while preserving the OpenRouter-first fallback precedence behavior.

Changes

BYOK Provider Identifier Migration

Layer / File(s) Summary
Provider contract and model catalog update
packages/grida-ai-agent/src/protocol/provider-ids.ts, packages/grida-ai-models/src/models.ts, packages/grida-ai-models/__tests__/models.test.ts, packages/grida-ai-agent/src/__public-api__.test.ts
BYOK_PROVIDER_METADATA is updated with { id: "vercel", label: "Vercel" } replacing the ai-gateway entry. The exported models.Provider type and all 10 image model catalog entries update their provider field from "gateway" to "vercel". Test expectations are updated to assert the new provider identity.
BYOK factory implementation and provider resolution
packages/grida-ai-agent/src/providers/byok.ts, packages/grida-ai-agent/src/providers/index.ts, packages/grida-ai-agent/src/providers/index.test.ts
makeAiGatewayFactory is renamed to makeVercelFactory. The provider resolver is updated to import and use makeVercelFactory in the switch case for "vercel" provider ID, and precedence documentation is updated to state OpenRouter takes priority over Vercel with fail-closed ProviderUnavailableError. Resolver tests updated to assert Vercel as the fallback when OpenRouter key is absent.
Sandbox policy and secrets configuration
packages/grida-ai-agent/src/sandbox/policy.ts, packages/grida-ai-agent/src/secrets.ts, packages/grida-ai-agent/src/http/routes/secrets.ts, packages/grida-ai-agent/src/auth/file.ts
Network allowlist in sandbox policy updated with Vercel domain patterns (ai-gateway.vercel.sh, *.vercel-ai.com). Secrets store and HTTP routes documentation updated to reference vercel. Auth file documentation examples changed to show vercel as the supported provider.
User-facing documentation and configuration
docs/contributing/billing.md, docs/wg/ai/grida/architecture.md, editor/.env.example, editor/lib/ai/models.ts, editor/lib/desktop/bridge.test.ts
Billing, architecture, and environment configuration documentation updated to state precedence is OpenRouter then Vercel (instead of OpenRouter then AI Gateway). Architecture test pins updated to assert OpenRouter preference over Vercel BYOK. Editor bridge test updated to expect ["openrouter", "vercel"] from secrets.byokProviders().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • gridaco/grida#718: Both PRs address BYOK provider resolution; this PR updates the documented and implemented provider identity from ai-gateway to vercel, aligning with the foundational BYOK carve-out built in the referenced PR.

Suggested labels

ai, breaking

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: renaming the BYOK provider ID from 'ai-gateway' to 'vercel', which is the primary refactoring objective across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/byok-provider-id-vercel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/grida-ai-agent/src/auth/file.ts (1)

138-138: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix CI-blocking typo in comment.

unparseable should be unparsable to satisfy the typos check.

Suggested patch
-        // override was unparseable — fall through to disk
+        // override was unparsable — fall through to disk
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/grida-ai-agent/src/auth/file.ts` at line 138, Update the comment
containing "override was unparseable — fall through to disk" in
packages/grida-ai-agent/src/auth/file.ts to correct the spelling from
"unparseable" to "unparsable"; locate the comment text (the line with "override
was unparseable") and change only that word so the typos check passes without
altering surrounding code or logic.

Source: Pipeline failures

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/grida-ai-agent/src/auth/file.ts`:
- Line 138: Update the comment containing "override was unparseable — fall
through to disk" in packages/grida-ai-agent/src/auth/file.ts to correct the
spelling from "unparseable" to "unparsable"; locate the comment text (the line
with "override was unparseable") and change only that word so the typos check
passes without altering surrounding code or logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08be8851-dd33-4d95-9e7d-6bc9fc2dd1af

📥 Commits

Reviewing files that changed from the base of the PR and between d081ae4 and b0f5bd0.

📒 Files selected for processing (16)
  • docs/contributing/billing.md
  • docs/wg/ai/grida/architecture.md
  • editor/.env.example
  • editor/lib/ai/models.ts
  • editor/lib/desktop/bridge.test.ts
  • packages/grida-ai-agent/src/__public-api__.test.ts
  • packages/grida-ai-agent/src/auth/file.ts
  • packages/grida-ai-agent/src/http/routes/secrets.ts
  • packages/grida-ai-agent/src/protocol/provider-ids.ts
  • packages/grida-ai-agent/src/providers/byok.ts
  • packages/grida-ai-agent/src/providers/index.test.ts
  • packages/grida-ai-agent/src/providers/index.ts
  • packages/grida-ai-agent/src/sandbox/policy.ts
  • packages/grida-ai-agent/src/secrets.ts
  • packages/grida-ai-models/__tests__/models.test.ts
  • packages/grida-ai-models/src/models.ts

@softmarshmallow softmarshmallow merged commit c2f7706 into main Jun 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant